import request from '@/utils/request'

/**
 * 获取角色列表
 * @param {*} query 查询参
 * @returns
 */
export const getRoleListAPI = query => {
  return request({
    method: 'get',
    url: '/sys/role',
    params: query
  })
}

/**
 * 删除角色
 * @param {String} roleId 角色Id
 * @returns
 */
export const delRoleAPI = roleId => {
  return request({
    method: 'delete',
    url: `/sys/role/${roleId}`
  })
}
// 新增角色
export const addRoleAPI = roleForm => {
  return request({
    method: 'post',
    url: '/sys/role',
    data: roleForm
  })
}
// 获取角色详情
export const getRoleDetailAPI = roleId => {
  return request({
    method: 'get',
    url: `/sys/role/${roleId}`
  })
}
// 编辑角色
export const editRoleAPI = roleForm => {
  return request({
    method: 'put',
    url: `/sys/role/${roleForm.id}`,
    data: roleForm
  })
}
//
export const getCompanyDetailAPI = companyId => {
  return request({
    method: 'get',
    url: `/company/${companyId}`
  })
}

/**
 * 给角色分配权限
 * @param {String} id 角色id
 * @param {*} permIds 权限数组
 * @returns Promise
 */
export const assignPermAPI = (id, permIds) => {
  return request({
    method: 'put',
    url: `/sys/role/assignPrem`,
    data: {
      id,
      permIds
    }
  })
}
